﻿using System.Web;

namespace TNPTN.Utility
{
    /// <summary>
    /// Common Utility
    /// Author: jabraok
    /// </summary>
    public static class Common
    {
        /// <summary>
        /// Get IP Address
        /// </summary>
        /// <param name="request">HttpRequestBase</param>
        /// <returns>IP Address</returns>
        public static string getIPAddress(HttpRequestBase request)
        {
            string szRemoteAddr = request.UserHostAddress;
            string szXForwardedFor = request.ServerVariables["X_FORWARDED_FOR"];
            string szIP = "";

            if (szXForwardedFor == null)
            {
                szIP = szRemoteAddr;
            }
            else
            {
                szIP = szXForwardedFor;
            }
            return szIP;
        }

        /// <summary>
        /// Fix akhar klah di html
        /// Author: jayam
        /// </summary>
        /// <param name="s">string value</param>
        /// <returns>string html replaced</returns>
        public static string FixInputAkharCam(string s)
        {
            return s.Replace("<", "&#60;");
        }
    }
}